package br.inf.prismasoft.academix.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Turma generated by hbm2java
 */
@Entity
@Table(name = "TURMA", schema = "ACADEMIX")
public class Turma implements java.io.Serializable {

	private static final long serialVersionUID = -7890228441423298793L;
	private Integer idtTurma;
	private GradeCurricular gradeCurricular;
	private String codTurma;
	private int numAno;
	private int numSemestre;
	private int numPeriodoVigente;
	private Set<Falta> faltas = new HashSet<Falta>(0);
	private Set<Avaliacao> avaliacaos = new HashSet<Avaliacao>(0);
	private Set<Aluno> alunos = new HashSet<Aluno>(0);
	private Set<GradeHoraria> gradeHorarias = new HashSet<GradeHoraria>(0);

	public Turma() {
	}

	public Turma(GradeCurricular gradeCurricular, String codTurma, int numAno,
			int numSemestre, int numPeriodoVigente) {
		this.gradeCurricular = gradeCurricular;
		this.codTurma = codTurma;
		this.numAno = numAno;
		this.numSemestre = numSemestre;
		this.numPeriodoVigente = numPeriodoVigente;
	}

	public Turma(GradeCurricular gradeCurricular, String codTurma, int numAno,
			int numSemestre, int numPeriodoVigente, Set<Falta> faltas,
			Set<Avaliacao> avaliacaos, Set<Aluno> alunos,
			Set<GradeHoraria> gradeHorarias) {
		this.gradeCurricular = gradeCurricular;
		this.codTurma = codTurma;
		this.numAno = numAno;
		this.numSemestre = numSemestre;
		this.numPeriodoVigente = numPeriodoVigente;
		this.faltas = faltas;
		this.avaliacaos = avaliacaos;
		this.alunos = alunos;
		this.gradeHorarias = gradeHorarias;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "idt_turma", unique = true, nullable = false)
	public Integer getIdtTurma() {
		return this.idtTurma;
	}

	public void setIdtTurma(Integer idtTurma) {
		this.idtTurma = idtTurma;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ind_grade_curricular", nullable = false)
	@NotNull
	public GradeCurricular getGradeCurricular() {
		return this.gradeCurricular;
	}

	public void setGradeCurricular(GradeCurricular gradeCurricular) {
		this.gradeCurricular = gradeCurricular;
	}

	@Column(name = "cod_turma", nullable = false, length = 10)
	@NotNull
	@Length(max = 10)
	public String getCodTurma() {
		return this.codTurma;
	}

	public void setCodTurma(String codTurma) {
		this.codTurma = codTurma;
	}

	@Column(name = "num_ano", nullable = false)
	@NotNull
	public int getNumAno() {
		return this.numAno;
	}

	public void setNumAno(int numAno) {
		this.numAno = numAno;
	}

	@Column(name = "num_semestre", nullable = false)
	@NotNull
	public int getNumSemestre() {
		return this.numSemestre;
	}

	public void setNumSemestre(int numSemestre) {
		this.numSemestre = numSemestre;
	}

	@Column(name = "num_periodo_vigente", nullable = false)
	@NotNull
	public int getNumPeriodoVigente() {
		return this.numPeriodoVigente;
	}

	public void setNumPeriodoVigente(int numPeriodoVigente) {
		this.numPeriodoVigente = numPeriodoVigente;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "turma")
	public Set<Falta> getFaltas() {
		return this.faltas;
	}

	public void setFaltas(Set<Falta> faltas) {
		this.faltas = faltas;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "turma")
	public Set<Avaliacao> getAvaliacaos() {
		return this.avaliacaos;
	}

	public void setAvaliacaos(Set<Avaliacao> avaliacaos) {
		this.avaliacaos = avaliacaos;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "ALUNO_TURMA", schema = "ACADEMIX", joinColumns = { @JoinColumn(name = "ind_turma", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "ind_aluno", nullable = false, updatable = false) })
	public Set<Aluno> getAlunos() {
		return this.alunos;
	}

	public void setAlunos(Set<Aluno> alunos) {
		this.alunos = alunos;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "turma")
	public Set<GradeHoraria> getGradeHorarias() {
		return this.gradeHorarias;
	}

	public void setGradeHorarias(Set<GradeHoraria> gradeHorarias) {
		this.gradeHorarias = gradeHorarias;
	}

}
